﻿<%@ Control Language="VB" AutoEventWireup="false" CodeFile="ManageRole.ascx.vb" Inherits="WebForm_ManageRole_ManageRole" %>
<%@ Register src="OpenManageRoleBrandMapping.ascx" tagname="OpenManageRoleBrandMapping" tagprefix="uc1" %>
<%@ Register src="OpenManageRoleChannelMapping.ascx" tagname="OpenManageRoleChannelMapping" tagprefix="uc1" %>
<%@ Register src="OpenManageRoleProgramMapping.ascx" tagname="OpenManageRoleProgramMapping" tagprefix="uc1" %>
<asp:Panel ID="Panel1" runat="server" GroupingText="<%$ Resources:AddNewRole %>">
    <asp:FormView ID="FormView1" runat="server" DefaultMode="Insert" Width="100%">
        <InsertItemTemplate>
            <table cellpadding="0" cellspacing="0" width="100%">
                <tr>
                    <td align="right">
                        <asp:Label ID="lblParent" runat="server" Text="<%$ Resources:Parent %>"></asp:Label>
                    </td>
                    <td>
                        <TServerControl:TDropDownList ID="ddlParent" runat="server" DataSourceID="ObjectDataSource_SelectAllPapas"
                    DataTextField="RoleName" DataValueField="RoleID" AutoPostBack="True" 
                            onselectedindexchanged="ddlRolePapas_SelectedIndexChanged">
                        </TServerControl:TDropDownList>
                        <asp:ObjectDataSource ID="ObjectDataSource_SelectAllPapas" runat="server" 
                            OldValuesParameterFormatString="original_{0}" SelectMethod="BLL_SelectAllRoles" 
                            TypeName="BLL_ManageRole"></asp:ObjectDataSource>
                    </td>
                    <td align="right">
                        <asp:Label ID="lblDivision" runat="server" Text="<%$ Resources:Division %>"></asp:Label>
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlDivision" runat="server">
                        </asp:DropDownList>
                    </td>
                    <td>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <asp:Label ID="lblRoleName" runat="server" Text="<%$ Resources:RoleName %>"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="txtRoleName" runat="server" MaxLength="50"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="chk_txtRoleName" runat="server" 
                            ControlToValidate="txtRoleName" Display="None" SetFocusOnError="true"
                            ErrorMessage="<%$ Resources:chk_txtRoleName %>" ValidationGroup="Insert"></asp:RequiredFieldValidator>
                    </td>
                    <td align="right">
                        <asp:Label ID="lblRoleDescription" runat="server" 
                    Text="<%$ Resources:RoleDescription %>"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="txtRoleDescription" runat="server" MaxLength="50" ></asp:TextBox>
                        <asp:RequiredFieldValidator ID="chk_txtRoleDescription" runat="server" 
                            ControlToValidate="txtRoleDescription" Display="None" SetFocusOnError="true"
                            ErrorMessage="<%$ Resources:chk_txtRoleDescription %>" ValidationGroup="Insert"></asp:RequiredFieldValidator>
                    </td>
                    <td>
                        <asp:Button ID="btnAdd" runat="server" OnClick="btnAdd_Click" Text="<%$ Resources:Add %>" ValidationGroup="Insert" />
                    </td>
                </tr>
            </table>
        </InsertItemTemplate>
    </asp:FormView>
</asp:Panel>
<br/>
<asp:Panel ID="Panel2" runat="server" GroupingText="<%$ Resources:RoleList %>">
    <table cellpadding="0" cellspacing="0" width="100%">
        <tr style="display:none">
            <td align="right">
                <asp:Label ID="lblRoleName" runat="server" Text="<%$ Resources:RoleName %>"></asp:Label>
            </td>
            <td colspan="4">
                <asp:TextBox ID="txtRoleName" runat="server" MaxLength="50"></asp:TextBox>
                <asp:Button ID="btnSearch" runat="server" Text="<%$ Resources:Search %>" />
            </td>
        </tr>
        <tr>
            <td colspan="5">
                <My:MyGridView ID="TGridView1" runat="server" AllowHoverEffect="True"
            AllowHoverSelect="True" DataSourceID="ObjectDataSource_Role" ShowFooterWhenEmpty="False"
            ShowHeaderWhenEmpty="False" TotalRowCount="0" 
            AutoGenerateColumns="False" DataKeyNames="RoleID"
            SkinID="pager" onrowupdating="TGridView1_RowUpdating" 
                    onrowdatabound="TGridView1_RowDataBound" 
                    onrowupdated="TGridView1_RowUpdated">
                    <Columns>
                        <asp:TemplateField>
                            <EditItemTemplate>
                                <asp:LinkButton ID="lbtnUpdate" runat="server" Text="<%$ Resources:Update %>" ValidationGroup="Update"
                            CommandName="Update"></asp:LinkButton>
                                <asp:LinkButton ID="lbtnCancel" runat="server" Text="<%$ Resources:Cancel %>" CommandName="Cancel"
                            CausesValidation="False"></asp:LinkButton>
                                &nbsp;
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:LinkButton ID="lbtnEdit" runat="server" Text="<%$ Resources:Edit %>" CommandName="Edit"
                            CausesValidation="False" Visible='<%# BooleanConverter(Eval("CanEdit")) %>'></asp:LinkButton>
                                &nbsp;<asp:LinkButton ID="lbtnDelete" runat="server" CausesValidation="False" 
                                    CommandName="Delete" onclientclick="<%$ Resources:DeleteConfirm %>" 
                                    Text="<%$ Resources:Delete %>" 
                                    Visible='<%# BooleanConverter(Eval("CanEdit")) %>'></asp:LinkButton>
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center" width="60px" />
                        </asp:TemplateField>
                        <asp:BoundField DataField="ParentName" 
                    HeaderText="<%$ Resources:bfParent %>" SortExpression="ParentName"
                    ReadOnly="True" >
                        </asp:BoundField>
                        <asp:TemplateField HeaderText="<%$ Resources:bfDivision %>" 
                    SortExpression="Division">
                            <EditItemTemplate>
                                <asp:DropDownList ID="ddlDivision" runat="server"/>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="lblDivision" runat="server" Text='<%# Eval("Division") %>'></asp:Label>
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="<%$ Resources:bfRoleName %>" 
                    SortExpression="RoleName">
                            <EditItemTemplate>
                                <asp:TextBox ID="txtRoleName0" runat="server" Text='<%# Bind("RoleName") %>' 
                            MaxLength="50" Width="90%"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="chk_txtRoleName0" runat="server" 
                                    ControlToValidate="txtRoleName0" Display="None" 
                                    ErrorMessage="<%$ Resources:chk_txtRoleName %>" ValidationGroup="Update"></asp:RequiredFieldValidator>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Bind("RoleName") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="<%$ Resources:bfRoleDescription %>" 
                    SortExpression="RoleDescription">
                            <EditItemTemplate>
                                <asp:TextBox ID="txtRoleDescription0" runat="server" 
                            Text='<%# Bind("RoleDescription") %>' MaxLength="50" Width="90%"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="chk_txtRoleDescription0" runat="server" 
                                    ControlToValidate="txtRoleDescription0" Display="None" SetFocusOnError="true"
                                    ErrorMessage="<%$ Resources:chk_txtRoleDescription %>" ValidationGroup="Update"></asp:RequiredFieldValidator>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label2" runat="server" Text='<%# Bind("RoleDescription") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="<%$ Resources:Active %>" SortExpression="Active">
                            <EditItemTemplate>
                                <asp:CheckBox ID="chkActive" runat="server" 
                            Checked='<%# BooleanConverter(Eval("Active")) %>' />
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:CheckBox ID="chkActive0" runat="server" 
                            Checked='<%# BooleanConverter(Eval("Active")) %>' Enabled="False" />
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="<%$ Resources:Product %>">
                            <EditItemTemplate>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Button runat="server" onclick="btnProduct_Click"  Text="<%$ Resources:Setup %>"></asp:Button>
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="<%$ Resources:Channel %>">
                            <EditItemTemplate>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Button runat="server" onclick="btnChannel_Click"  Text="<%$ Resources:Setup %>"></asp:Button>
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="<%$ Resources:Function %>">
                            <EditItemTemplate>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Button runat="server" onclick="btnFunction_Click"  Text="<%$ Resources:Setup %>"></asp:Button>
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </asp:TemplateField>
                    </Columns>
                </My:MyGridView>
            </td>
        </tr>
    </table>
</asp:Panel>
            
            <asp:ObjectDataSource ID="ObjectDataSource_Role" runat="server" InsertMethod="BLL_Insert"
                OldValuesParameterFormatString="original_{0}" 
                SelectMethod="BLL_Select" TypeName="BLL_ManageRole" UpdateMethod="BLL_Update" 
                DeleteMethod="BLL_Delete" onupdated="ObjectDataSource_Role_Updated">
                <DeleteParameters>
                    <asp:Parameter Name="original_RoleID" Type="Int32" />
                </DeleteParameters>
                <UpdateParameters>
                    <asp:Parameter Name="original_RoleID" Type="Int32" />
                    <asp:Parameter Name="RoleName" Type="String" />
                    <asp:Parameter Name="RoleDescription" Type="String" />
                    <asp:Parameter Name="Division" Type="String" />
                    <asp:Parameter Name="Active" Type="String" />
                </UpdateParameters>
                <SelectParameters>
                    <asp:Parameter Name="PapaID" Type="String" />
                    <asp:Parameter Name="Parent" Type="String" />
                </SelectParameters>
                <InsertParameters>
                    <asp:Parameter Name="Parent" Type="Int32" />
                    <asp:Parameter Name="RoleName" Type="String" />
                    <asp:Parameter Name="RoleDescription" Type="String" />
                    <asp:Parameter Name="Division" Type="String" />
                </InsertParameters>
            </asp:ObjectDataSource>
            <uc1:OpenManageRoleProgramMapping ID="OpenManageRoleProgramMapping1" runat="server"  />
            <uc1:OpenManageRoleChannelMapping ID="OpenManageRoleChannelMapping1" runat="server"  />
            <uc1:OpenManageRoleBrandMapping ID="OpenManageRoleBrandMapping1" runat="server"  />
            <asp:ValidationSummary ID="sum_Insert" runat="server" DisplayMode="List" 
                ShowMessageBox="True" ShowSummary="False" ValidationGroup="Insert" />
            <asp:ValidationSummary ID="sum_Update" runat="server" DisplayMode="List" 
                ShowMessageBox="True" ShowSummary="False" ValidationGroup="Update" />